package com.nannybear.Communication;

import android.os.AsyncTask;

/**
 * @brief Use to send the frame and check if the robot received it.
 */
public class EmissionTask extends AsyncTask<String, Integer, String>{
    /********** DECLARATIONS **********/
    private Connection connection;

    /************ METHODS ************/
    /**
     * @brief Constructor.
     */
    public EmissionTask(Connection connection){
        this.connection = connection;
    }

    /**
     * @brief Task in background to send the message.
     */
    protected String doInBackground(String...param){
        String message = null;
        message = this.sendToNannyBear(param[0]);
        return message;
    }

    /**
     * @brief Send the message.
     */
    private String sendToNannyBear(String message){
        String ack = null;
        this.connection.write(message);
        //TODO : traiter le ack de reception du mesage
        return ack;
    }
}
